package com.practice.datasource;

import com.practice.entity.Employee;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;

public class TestDataSource {
    public static void main(String[] args) throws SQLException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        String sql = "select * from employee where id = ?";
        BasicDataSource basicDataSource = new BasicDataSource();
        JDBC4DataSourceTemplate base = new JDBC4DataSourceTemplate(basicDataSource);
        Employee employee1 = base.queryForObject(
                sql,
                new Object[] {1},
                Employee.class
        );
        System.out.println(employee1);

        DBCPDataSource dbcpDataSource = new DBCPDataSource(5);
        JDBC4DataSourceTemplate dbcp = new JDBC4DataSourceTemplate(dbcpDataSource);
        Employee employee2 = base.queryForObject(
                sql,
                new Object[] {2},
                Employee.class
        );
        System.out.println(employee2);

    }
}
